package com.web.portal.service;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.web.portal.dao.AdvisorMeetingSearchType;
import com.web.portal.dao.BaseDao;
import com.web.portal.entity.AdvisorMeeting;
@Service(value="advisorMeetingService")
public class DefaultAdvisorMeetingService extends DefaultWebPortalService<AdvisorMeeting> implements AdvisorMeetingService {
private static final Logger LOG= Logger.getLogger(DefaultAdvisorMeetingService.class);
	
	@Autowired
	@Qualifier(value="advisorMeetingDao")
	public void init(BaseDao dao){
		setBaseDao(dao);
	}
	public AdvisorMeeting getAdvisorMeeting(String id) {
		// TODO Auto-generated method stub
		Map<AdvisorMeetingSearchType, Object> searchCriteria= new EnumMap(AdvisorMeetingSearchType.class);
		searchCriteria.put(AdvisorMeetingSearchType.ID,id);
		List<AdvisorMeeting> result= searchByCriteria(searchCriteria);
		if(!result.isEmpty()&& result.size()==1){
			LOG.debug("Unique Advisor Meeting found..............................");
			return result.get(0);
		}
		LOG.debug("Advisor Meeting not found......................................");
		return null;
	}
	public List<AdvisorMeeting> getAllAdvisorMeeting(
			AdvisorMeeting advisorMeeting) {
		// TODO Auto-generated method stub
		return getList(advisorMeeting);
	}

	@Override
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	protected boolean isCreate(AdvisorMeeting entity) throws RuntimeException {
		// TODO Auto-generated method stub
		return false;
	}
	public void createOrSave(AdvisorMeeting advisorMeeting){
		createOrUpdate(advisorMeeting);
	}

}
